/**
    GpsNetwork lets you download files and log some system parameters from NetRs DGPS receivers.
    
    Copyright (C) 2009  Eduardo Maureira
    
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    email:emaureir@gmail.com
 */
package io;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

import org.apache.log4j.Logger;

/**
 * Lector simple de un archivo de Texto.
 * @author eduardo
 *
 */
public class Lector {
	private static final Logger logger = Logger.getLogger(Lector.class);

	private String archivo;
	private BufferedReader in;

    /**
     * 
     * @param archivo Ruta del archivo a leer
     */
	public Lector(String archivo) {
		super();
		this.archivo = archivo;
	}
	
	
	/**
	 * Prepara el archivo para la lectura
	 *
	 */
	  public void Open() 
	  {

		    try {
		        in = new BufferedReader(new FileReader(archivo));
		    } catch (IOException e) {
		    }	    
	  }
	  
	  /**
	   * Libera los recursos utilizados para la lectura
	   */
		public void Close ()
		{
		      // dispose all the resources after using them.
	        try {
	        	if (in!=null){
	        		in.close();
	        	}
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}



	public String getArchivo() {
			return archivo;
		}


		public void setArchivo(String archivo) {
			this.archivo = archivo;
		}





	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args)  {
		Lector lector;
		lector = new Lector ("/home/eduardo/unavco/teqc/salida2.obs");
		lector.Open();
		BufferedReader in;
		in = lector.getIn();
		String linea;
		try {
			while ((linea=in.readLine())!=null){
				logger.debug(linea);
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		lector.Close();

	}


	/**
	 * este metodo permite acceder al
	 * readLine de esta clase
	 * @return
	 */
	public BufferedReader getIn() {
		return in;
	}


	public void setIn(BufferedReader in) {
		this.in = in;
	}

}
